package solver
/*
import "slices"

type XYWCell struct {
	boxNum     int
	cellNum    int
	rowNum     int
	colNum     int
	candidates []int
}

type XYWGrid struct {
	boxes [9][]*XYWCell
	rows  [9][]*XYWCell
	cols  [9][]*XYWCell
}

func (g *Grid) getXYWingCells() (xywBoxes [9][]*XYWCell, xywRows [9][]*XYWCell, xywCols [9][]*XYWCell) {

	for rowNum := 1; rowNum < 9; rowNum++ {
		for colNum := 1; colNum < 9; colNum++ {
			cell := g.cells[rowNum][colNum]
			if cell.candidateCount != 2 {
				continue
			}
			boxNum, cellNum := calcBoxAndCellNum(rowNum, colNum)
			cands := [2]int{}
			i := 0
			for cand, candidate := range g.cells[rowNum][colNum].candidates {
				if candidate {
					cands[i] = cand
					i++
					if i == 1 {
						break
					}
				}
			}
			xywCell := XYWCell{boxNum, cellNum, rowNum, colNum, cands[:]}
			xywBoxes[boxNum] = append(xywBoxes[boxNum], &xywCell)
			xywRows[rowNum] = append(xywRows[rowNum], &xywCell)
			xywCols[colNum] = append(xywCols[colNum], &xywCell)
		}
	}
	return xywBoxes, xywRows, xywCols
}

func (g *Grid) XYWing() (used bool) {
	xywBoxes, xywRows, xywCols := g.getXYWingCells()
	for _, xywRow := range xywRows {
		for _, xyCell := range xywRow {
			xzCells := findXZ(xywRow, xyCell)
			for _, xzCell := range xzCells {
				xywCol := xywCols[xyCell.colNum]
				if g.doYZfromXYandXZ(xyCell, xzCell, xywCol) {
					used = true
				}
			}

			xzCells = findXZ(xywBoxes[xyCell.boxNum], xyCell)
			for _, xzCell := range xzCells {
				xywRow := xywRows[xyCell.rowNum]
				if g.doYZfromXYandXZ(xyCell, xzCell, xywRow) {
					used = true
				}

				xywCol := xywCols[xyCell.colNum]
				if g.doYZfromXYandXZ(xyCell, xzCell, xywCol) {
					used = true
				}
			}
		}
	}

	return
}

func findXZ(xywBoxes []*XYWCell, xyCell *XYWCell) []*XYWCell {
	return []*XYWCell{}
}

func (g *Grid) doYZfromXYandXZ(xyCell *XYWCell, xzCell *XYWCell, xywCol []*XYWCell) (used bool) {
	yz := sliceDiff(xyCell.candidates, xzCell.candidates)
	yzCells := findYZ(xywCol, yz, xyCell)
	for _, yzCell := range yzCells {
		if g.clearupXYWing(xzCell, yzCell) {
			used = true
		}
	}
	return
}

func findYZ(xywCol []*XYWCell, yz []int, xyCell *XYWCell) []*XYWCell {
	return nil
}

func (g *Grid) clearupXYWing(xzCell *XYWCell, yzCell *XYWCell) (used bool) {
	return
}

func sliceDiff(vs1 []int, vs2 []int) []int {
	slices.Sort(vs1)
	slices.Sort(vs2)
	i := 0
	j := 0
	vs := []int{}
	for i < len(vs1) && j < len(vs2) {
		if vs1[i] < vs2[j] {
			vs = append(vs, vs1[i])
			i++
		} else if vs1[i] > vs2[j] {
			vs = append(vs, vs2[j])
			j++
		} else {
			i++
			j++
		}
	}
	if i < len(vs1) {
		vs = append(vs, vs1[i:]...)
	}
	if j < len(vs2) {
		vs = append(vs, vs2[j:]...)
	}
	return vs
}
*/